package com.campus.controller;

import com.campus.entry.ManagerActivity;
import com.campus.pojo.dto.ManagerActivityDto;
import com.campus.response.ResponseResult;
import com.campus.response.ResultCode;
import com.campus.service.ManagerActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/activity")
public class ManagerActivityController {
    @Autowired
    private ManagerActivityService managerActivityService;
    @PostMapping("/create")
    public ResponseResult<Object> createActivity(@RequestBody ManagerActivity managerActivity){
        managerActivityService.saveActivity(managerActivity);
        return new ResponseResult<>(ResultCode.ALL_SUCCESS,null);
    }
    @PutMapping("/update")
    public ResponseResult<Object> updateActivity(@RequestBody ManagerActivity managerActivity){
        managerActivityService.updateActivity(managerActivity);
        return new ResponseResult<>(ResultCode.ALL_SUCCESS,null);

    }
    @PutMapping("/publish")
    public ResponseResult<Object> publishActivity(@RequestParam Integer activityId){
        managerActivityService.publishActivity(activityId);
        return new ResponseResult<>(ResultCode.ALL_SUCCESS,null);
    }
    @GetMapping("/list")
    public ResponseResult<List<ManagerActivity>> listActivity(@RequestBody ManagerActivityDto managerActivityDto){
        System.out.println(managerActivityDto);
        List<ManagerActivity> managerActivities = managerActivityService.listManagerActivity(managerActivityDto);
        return new ResponseResult<>(ResultCode.ALL_SUCCESS,managerActivities);
    }
}
